#! usr/bin/python
dayList = list() #This list of events to display
eventList = list()


def popDays():
   eventList.append({"title": "An event", "dateOccurs": "13/4/09", "active": True})
   eventList.append({"title": "Another event", "dateOccurs": "14/4/09", "active": True})
   eventList.append({"title": "A third event", "dateOccurs": "14/4/09", "active": True})
   
   dayList.append({"day": "Mon", "event": (eventList[0],)})
   dayList.append({"day": "Tue", "event": (eventList[1],eventList[2])})
   dayList.append({"day": "Wed"})
   dayList.append({"day": "Thu"})
   dayList.append({"day": "Fri"})
   dayList.append({"day": "Sat"})
   dayList.append({"day": "Sun"})

def printDayList(days_only = True):
   for day in dayList:
       if days_only:
           print "Working day is: %s" % day["day"]
       else:
           print day

def printDaysEvents(chosenDay):
   try:
       for event in chosenDay["event"]:
           print event["title"], ",", event["active"]
   except KeyError, e:
       print "Selected day (%s) doesn't have any events. Code: %s" % (chosenDay["day"], e)


print "Start up: Populating event list"
popDays()

print "Default data"
printDayList()

workingDay = int(raw_input("Select working day: ")) - 1
print dayList[workingDay]["day"]

print
workingEvent = dayList[workingDay]

print "Data for working event: %s" % str(workingEvent["day"])
printDaysEvents(workingEvent)

print
print "All data"
printDayList(False) 
